const querystring = require('querystring')
const util = {
  goToList: (project, blc) => {
    this.$router.push({
      name: 'projectList',
      query: {
        project: project,
        blc: blc
      }
    })
  },
  goLogin: () => {
    var authorUrl = 'https://jaccount.sjtu.edu.cn/oauth2/authorize'
    let state = 1
    let redirectUri = window.location.href
    let scope = 'basic essential'

    authorUrl = authorUrl + ('?' + querystring.stringify({
      client_id: 'yuK32E6bPbeNalTJzUru',
      response_type: 'code',
      scope: scope,
      state: state,
      redirect_uri: redirectUri
    }))

    window.location.href = authorUrl
  },

  goLogout: () => {
    var authorUrl = 'https://jaccount.sjtu.edu.cn/oauth2/logout'
    // let state = 1
    let redirectUri = window.location.host
    // let scope = 'basic essential'

    authorUrl = authorUrl + ('?' + querystring.stringify({
      client_id: 'yuK32E6bPbeNalTJzUru',
      // response_type: 'code',
      // scope: scope,
      // state: state,
      redirect_uri: redirectUri
    }))

    console.log(authorUrl)

    // window.location.href = authorUrl
  }
}

export default util
